<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";


$strSql = "select max(id)+1 as id  from solotb_empresa";
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);

if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR=1;
    $err=0;
}else {
    $data = $oConexion->getData("NUM");
    $MaxId = $data[0][0];
    $oConexion->liberarResultado();
    $oConexion->Cerrar();
}

$strSql = "select * from solotb_empresa order by des";
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);

if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR = 1;
    $err = 0;
}
$arrData = $oConexion->getData("NUM");
$oConexion->liberarResultado();
$oConexion->Cerrar();

?>
<html>
    <head>
        <title>Documentaci&oacute;n</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT>
    </head>

    <body leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">
        <p align="center" class="SoloStyle_titulopaginas">Tabla de Empresas</p>
        <form name="frmIngreso" action="trn_GrabaEmpresa2.php" method="POST">
            <input type="hidden" name="opc" value="C">

            <table border="0" width="70%" align="center">
                <tr>
                    <td class="SoloStyle_etiqueta"><b>Id</b></td>
                    <td class="SoloStyle_Texto"><?php echo $MaxId;?><input type="hidden" maxlenght="50" size="50" name="HidId" class="texto" value="<?php echo $MaxId;?>"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_etiqueta"><b>Nueva Empresa</b></td>
                    <td><input type="text" maxlenght="50" size="50" name="ATxtDesc" class="SoloStyle_Texto"></td>
                </tr>
            </table>
            <br><center>
                <!--<input type="button" name="CmdGrabar" value="Grabar" class="SoloStyle_boton" onClick="Submit_Form(document.frmIngreso)"></center>-->
                <input type="submit" name="CmdGrabar" value="Grabar" class="SoloStyle_boton"></center>
        </form>
        <table width="75%" border="0" align="center" class="SoloStyle_grid">
            <tr class="SoloStyle_etiqueta">
                <td width="60%">Empresas</td>
                <td width="40%">Acci&oacute;n</td>
            </tr>
            <?php for ($i = 0; $i < count($arrData); $i++) {?>
            <tr>
                <td><?php echo $arrData[$i][1];?></td>

                <td><a href="trn_GrabaEmpresa2.php?id=<?php echo $arrData[$i][0];?>&ds=<?php echo $arrData[$i][1];?>&opc=M">
                        <img src='iconos/soloico_modificar.gif' alt='Modificar' width="23" height="19" border='0' style='cursor:hand' ></a>&nbsp;
                    <a href="#" onClick="Comprobar('trn_GrabaEmpresa2.php?id=<?php echo $arrData[$i][0];?>&ds=<?php echo $arrData[$i][1];?>&opc=E')">
                        <img src='iconos/soloico_eliminar.gif' alt='Borrar Campos' width="23" height="19" border='0' style='cursor:hand'></a></td>
            </tr>
                <?php }?>
        </table>
    </body>
</html>

<SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT>


<script type="text/javascript">

    function Window_Onload(){
        var Mensaje;
        Mensaje = "<?php echo $_REQUEST["des"];?>"
        if ("<?php echo $_REQUEST["MiError"];?>"  != ""){

            if ("<?php echo $_REQUEST["MiError"];?>" == "0")
            alert (acentos("Operación OK"));
            else
                alert (Mensaje);
        }
    }

    function Comprobar(pagina){
        var conf;
        conf = confirm("Confirma Eliminar");
        if (conf)
            window.location.href = pagina;
    }
</script>